#pragma once

#include <sys_def.h>

// type字段的部分取值（可扩展取值范围）
enum {
	USB_DESC_TYPE_DEVICE = 1,
	USB_DESC_TYPE_CONFIG = 2,
	USB_DESC_TYPE_STRING = 3,
	USB_DESC_TYPE_INTERFACE = 4,
	USB_DESC_TYPE_ENDPOINT = 5,
	USB_DESC_TYPE_QUALIFIER = 6,
	USB_DESC_TYPE_IAD = 11,
	USB_DESC_TYPE_CDC_FUNC = 36,
};

// 描述符头
typedef struct {
	u8_s len;  // 描述符长度
	u8_s type; // 描述符类型
} __attribute__((packed)) usb_desc_base_t;

_Static_assert(sizeof(usb_desc_base_t) == 2,
	       "Struct usb_desc_t defined error!");

// 带sub_type的描述符头
typedef struct {
	usb_desc_base_t base; // 描述符头
	u8_s sub_type;	      // 描述符子类型
} __attribute__((packed)) usb_desc_base_sub_t;

_Static_assert(sizeof(usb_desc_base_sub_t) == 3,
	       "Struct usb_desc_base_sub_t defined error!");

// 类结构体
typedef struct {
	u8_s usb_class; // 类
	u8_s sub_class; // 子类
	u8_s proto;	// 协议
} __attribute__((packed)) usb_desc_class_t;

_Static_assert(sizeof(usb_desc_class_t) == 3,
	       "Struct usb_desc_class_t defined error!");
